class Solution {
public:
    bool isValid(string s) {
        if (s.size() & 1)return 0;
        stack<char>ans;
        unordered_map<char, char> mp = {
            {')', '('},
            {']', '['},
            {'}', '{'}
        };
        int cnt = 0;
        for (auto x : s) {
            if (mp.count(x)) {
                cout << "cnt==" << cnt++ << endl;
                if (ans.empty() || mp[x] != ans.top())return 0;
                ans.pop();
            }
            else ans.push(x);
        }
        return ans.empty();
    }
};